package cn.wolfcode.wolf2w.controller;


import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.StrategyCatalog;
import cn.wolfcode.wolf2w.interceptor.RequireLogin;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.service.ITravelService;
import cn.wolfcode.wolf2w.util.JsonResult;
import jdk.nashorn.internal.objects.annotations.Getter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IDestinationService destinationService;

    @Autowired
    private IRegionService regionService;

    @Autowired
    private ITravelService travelService;

    @Autowired
    private IStrategyService strategyService;


    @GetMapping("hotRegion")
    public Object hotRegion(){
        return JsonResult.success(regionService.hotRegion());
    }

    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> destinations = destinationService.queryDestByRegionId(regionId);
        return JsonResult.success(destinations);
    }


    @GetMapping("toasts")
    public Object toasts(String id){
        List<Destination> toasts = destinationService.queryToastsById(id);
        return JsonResult.success(toasts);
    }


    @GetMapping("detail")
    public Object detail(String id){
        Destination destination = destinationService.get(id);
        return JsonResult.success(destination);
    }

    @GetMapping("catalogs")
    public Object catalogs(String id){
        List<StrategyCatalog> catalogList = destinationService.queryCatalogByDestId(id);
        return JsonResult.success(catalogList);
    }



    @GetMapping("strategies/viewnumTop3logs")
    public Object viewnumTop3logs(String id){
        return JsonResult.success(strategyService.viewnumTop3logs(id));
    }


    @GetMapping("travels/viewnumTop3")
    public Object viewnumTop3(String id){
        return JsonResult.success(travelService.viewnumTop3(id));
    }

}
